using OrbitOne.CRMLyncInfoDashboard.CRM;

namespace OrbitOne.CRMLyncInfoDashboard.Shell
{
    public abstract class ActionLink
    {
        protected readonly DisplayFieldModel m_displayFieldModel;

        protected string FieldValue
        {
            get { return m_displayFieldModel.FieldValue; }
        }

        protected ActionLink(DisplayFieldModel displayFieldModel)
        {
            m_displayFieldModel = displayFieldModel;
        }

        public void Execute()
        {
            if (CanExecute())
            {
                ExecuteAction();
            }
        }

        protected abstract void ExecuteAction();

        protected bool CanExecute()
        {
            return DisplayFieldModel.m_clickablePattern.IsMatch(m_displayFieldModel.FieldValue);
        }
    }
}